added Feb 2001 SDK
[windows-sources.git] / shared source / sscli20 / samples / compilers / myc / src / varlist.cs
blob041c71353ce6c65b899bdef0de87d65eb88aed80
1 //------------------------------------------------------------------------------
2 // <copyright file="varlist.cs" company="Microsoft">
3 //
4 // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
5 //
6 // The use and distribution terms for this software are contained in the file
7 // named license.txt, which can be found in the root of this distribution.
8 // By using this software in any fashion, you are agreeing to be bound by the
9 // terms of this license.
10 //
11 // You must not remove this notice, or any other, from this software.
12 //
13 // </copyright>
14 //------------------------------------------------------------------------------
16 namespace MyC
18 using System;
19 using System.Collections;
21 public class VarList
23 Hashtable vhash;
24 int vindex;
26 public VarList()
28 vhash = new Hashtable(8); // arbitrary initial size
29 vindex = 0; // init the index count
32 public void add(Var e)
34 int index = vindex++;
35 e.setIndex(index);
36 vhash.Add(e.getName(), e);
37 vhash.Add(index, e);
40 public Var FindByName(String s)
42 Object o = vhash[s];
43 if (o == null)
44 return null;
45 return ((Var)o);
48 public Var FindByIndex(int i)
50 Object x = i;
51 Object o = vhash[x];
52 if (o == null)
53 return null;
54 return (Var)o;
57 public int Length()
59 return vindex; // number of items in hash